"""线索页面"""
from selenium.webdriver.common.by import By


from page.base_page import BasePage


class CluePage(BasePage):
    url="/index.php?m=leads"
    btn_add_clue_locator = (By.LINK_TEXT, "新建线索")
    table_locator = (By.CSS_SELECTOR, "#form1 > table > tbody")
    trs_locator = (By.TAG_NAME, "tr")
    show_locator = (By.LINK_TEXT, "查看")
    conversion_locator = (By.LINK_TEXT, "转换")
    modify_locator = (By.LINK_TEXT, "修改")
    subordinate_locator = (By.LINK_TEXT, "下属负责的")
    myclue_locator = (By.LINK_TEXT, "我负责的")
    transformed_locator = (By.LINK_TEXT, "已转换线索")
    save_success_locator = (By.CSS_SELECTOR, "body > div.container > div.alert.alert-success")
    # btn_back_locator = (By.CSS_SELECTOR, "#form1 > table > tfoot > tr > td > input:nth-child(3)")
    # table_locator = (By.CSS_SELECTOR, "#form1 > table > tbody")
    # trs_locator = (By.TAG_NAME, "tr")
    # show_locator = (By.LINK_TEXT, "查看")
    def click_add_clue(self):
        #点击新增线索#
        self.find_element(self.btn_add_clue_locator).click()
    def click_subordinate(self):
        #点击下属负责的线索#
        self.find_element(self.subordinate_locator).click()
    def click_myclue(self):
        #"点击我负责的线索#
        self.find_element(self.myclue_locator).click()
    def click_transformed(self):
        #点击已经转换的线索#
        self.find_element(self.transformed_locator).click()
    def click_show_clue(self):
        #点击第一行数据的查看#
        table=self.find_element(self.table_locator)
        trs=table.find_elements(*self.trs_locator)
        trs[0].find_element(*self.show_locator).click()
    def modified_clue(self):
        table = self.find_element(self.table_locator)
        trs = table.find_elements(*self.trs_locator)
        trs[0].find_element(*self.show_locator).click()
        self.find_element(self.modify_locator).click()
    def save_success_text(self):
        return   self.find_element(self.save_success_locator).text
    def transformed(self):
        self.find_element(self.transformed_locator).click()
    def click_conversion(self):
        #点击第一行数据的转换#
        table = self.find_element(self.table_locator)
        trs = table.find_elements(*self.trs_locator)
        trs[0].find_element(*self.conversion_locator).click()


